﻿using System.Linq;
using Creventive.Wpf.ShellFactory.Services;

namespace Creventive.Wpf.ShellFactory.Logging
{
    /// <summary>
    ///   A helper class to quickly retrieve the global logger service from the default service container.
    /// </summary>
    public static class Logger
    {
        /// <summary>
        ///   Gets the default (global) logger service, or returns the default TraceLogger if no global service has been registered.
        /// </summary>
        /// <value>The default.</value>
        public static ILoggerService Default
        {
            get { return ServiceContainer.Default.GetService<ILoggerService>() ?? TraceLogger.Default; }
        }

        /// <summary>
        ///   Gets a value indicating whether a global logger has been registered.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance is registered; otherwise, <c>false</c>.
        /// </value>
        public static bool IsRegistered
        {
            get { return ServiceContainer.Default.HasService<ILoggerService>(); }
        }
    }
}